package controller;

import java.awt.Desktop;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

import javax.swing.JButton;

/**
 * 
 * @author Nelly-Kim TRAN
 * 
 * To fire up the default email software when we click on someone's email address
 * 
 * @param bouton
 * 				to get the text written on the button (the email address)
 *
 */

public class EmailListener implements ActionListener{

	JButton bouton;
	
	public EmailListener(JButton bouton) {
		this.bouton=bouton;
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		
		try {
			Desktop.getDesktop().browse(new URI("mailto:"+ bouton.getText()));
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		} catch (URISyntaxException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
	}

}
